<template>
  <div class="app-container">
    <el-form ref="form" :model="card" label-width="120px">
      <el-form-item label="借阅人ID">
        <el-input v-model="student.sid"/>
      </el-form-item>
      <el-form-item label="借阅人">
        <el-input v-model="student.sname"/>
      </el-form-item>
      <el-form-item label="书名">
        <el-input v-model="book.name"/>
      </el-form-item>
      <el-form-item label="留言内容">
        <el-input v-model="card.content"/>
      </el-form-item>
      <!--      <el-form-item label="留言时间：">
              <el-date-picker
                v-model="card.cdate"
                type="date"
                placeholder="请选择时间"
                style="width: 100%"
              />
            </el-form-item>-->
      <el-form-item>
        <el-button type="primary" @click="onSubmit">新增留言</el-button>
        <el-button @click="onCancel">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import request from '@/utils/request'

export default {
  data() {
    return {
      card: {
        caid: '',
        content: '',
        cdate: ''
      },
      student: {
        sname: '',
        sid:''
      },
      book:{
        name:''
      }
    }
  },
  methods: {
    onSubmit() {
          this.card.caid = this.student.sid;

          // 请求接口 实现用户新增接口的调用
          request({
            url: "/library/message/save.do",
            method: "POST",
            data: this.card
          }).then(res => {
            if (res.code == 0) {
              //跳转到列表页面
              this.$router.push("/messagelist");
            }
          })
        },
    checkPass() {
    }
    ,
    onCancel() {
      this.$message({
        message: '取消书籍的新增',
        type: 'warning'
      })
    }
  }
}
</script>

<style scoped>
.line {
  text-align: center;
}
</style>

